package view.mediator.monster.large_monster
{
	import flash.system.System;
	
	import model.monster.MonsterModel;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import service.SQLService;
	
	import view.event.monster.TypeListViewEvent;
	
	
	/**
	 * TypeListView怪物分类列表界面中介
	 * @author £iang
	 * 
	 */	
	public class TypeListViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** monsterModel */
		[Inject]
		public var monsterModel:MonsterModel;
		/** sqlService */
		[Inject]
		public var sqlService:SQLService;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			addViewListener( TypeListViewEvent.READ_SELECT_LDETAIL, selectedMonsterHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理选中查看的怪物后派发的消息 
		 * @param event 选中查看的怪物后派发的消息 
		 * 
		 */		
		protected function selectedMonsterHandler( event:TypeListViewEvent ):void
		{
			monsterModel.curReadMonsterId = event.curReadMonsterId;
			sqlService.getCurReadLMonsterDetailInfo( event.curReadMonsterId );
			dispatch( event );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeViewListener( TypeListViewEvent.READ_SELECT_LDETAIL, selectedMonsterHandler );
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function TypeListViewMediator()
		{
			super();
		}
	}
}